package com.api.edc.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.api.edc.model.ApiConstant;
import com.api.edc.model.CustomerInfoResult;
import com.nova.edc.model.system.CustomerInfo;
import com.nova.edc.service.system.CustomerInfoService;

@Controller
@RequestMapping(value = "/appCustomer")
public class CustomerInfoAPIController {

	@Autowired
	private CustomerInfoService novaCustomerInfoService;

	@RequestMapping(value = "findChildCustomer.shtml")
	@ResponseBody
	public CustomerInfoResult findChildCustomer(HttpServletRequest request,
			String addBy) {
		CustomerInfoResult companyResult = new CustomerInfoResult();
		List<CustomerInfo> list = new ArrayList<CustomerInfo>();
		try {
			list = novaCustomerInfoService.findCustomerInfoListByRole(addBy,
					null, "", "desc");
			companyResult.setCode(ApiConstant.CODE_SUCCESS);
			companyResult.setMessage(ApiConstant.MESSAGE_SUCCESS);
			companyResult.setData(list);
		} catch (Exception e) {
			companyResult.setCode(ApiConstant.CODE_EXCEPTION);
			companyResult.setMessage(ApiConstant.MESSAGE_EXCEPTION);
		}
		return companyResult;
	}
}
